using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using DTO;
namespace DAO
{
    public static class GiaoVienDAO
    {
        #region Huynh Tan Cong
        //them giao vien
        public static bool ThemGiaoVien(GiaoVienDTO GiaoVienDTO)
        {
            OleDbConnection con = Dataprovider.ketnoicsdl();
            string sql = "INSERT INTO GiaoVien(MaGV, TenGV, DiaChi, DienThoai, MaMH, TrangThai) values('" + GiaoVienDTO.MaGV + "','" + GiaoVienDTO.TenGV + "','" + GiaoVienDTO.DiaChi + "','" + GiaoVienDTO.DienThoai + "','" + GiaoVienDTO.MaMH + "', 'Còn Dạy' )";
            return Dataprovider.chaycaulenh(sql, con);
        }
        //xoa giao vien
        public static bool XoaGiaoVien(GiaoVienDTO GiaoVienDTO)
        {
            OleDbConnection con = Dataprovider.ketnoicsdl();
            string sql = "UPDATE GiaoVien SET TrangThai='Nghỉ Dạy' where MaGV='" + GiaoVienDTO.MaGV + "'";
            return Dataprovider.chaycaulenh(sql, con);
        }
        //sua giao vien
        public static bool CapNhatGiaoVien(GiaoVienDTO GiaoVienDTO)
        {
            OleDbConnection con = Dataprovider.ketnoicsdl();
            string sql = "UPDATE GiaoVien SET TenGV='" + GiaoVienDTO.TenGV + "',DiaChi='" + GiaoVienDTO.DiaChi + "',DienThoai='" + GiaoVienDTO.DienThoai + "',MaMH='" + GiaoVienDTO.MaMH + "',TrangThai='" + GiaoVienDTO.TrangThai + "'  where MaGV='" + GiaoVienDTO.MaGV + "'";

            return Dataprovider.chaycaulenh(sql, con);
        }
        //danh sach giao vien
        public static DataTable DanhSachGiaoVien()
        {
            OleDbConnection con = Dataprovider.ketnoicsdl();
            string sql = "select g.MaGV, g.TenGV, g.DiaChi, g.DienThoai, m.TenMH, g.TrangThai from GiaoVien g, MonHoc m where g.MaMH=m.MaMH";
            return Dataprovider.laythongtinbang(sql, con);
        }
        //danh sach mon hoc
        public static DataTable DanhSachMonHoc()
        {
            OleDbConnection con = Dataprovider.ketnoicsdl();
            string sql = "select * from MonHoc";
            return Dataprovider.laythongtinbang(sql, con);
        }
        #endregion

        #region Nguyen Thanh Duy

        public static DataTable GetTableGV()
        {
            OleDbConnection con = Dataprovider.ketnoicsdl();
            string sql = "select * from giaovien";
            return Dataprovider.laythongtinbang(sql, con);
        }

        #endregion
    }
}
